package Touchy;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import project.V12;

/**
 * The MenuPanel class is the panel that shows the menu
 * It is used to show the instructions for the game, and is used by the user to start the game
 * 
 * @author Sletten
 *
 */

@SuppressWarnings("serial")
public class MenuPanel extends JPanel implements ActionListener
{
	private Touchy mTouchy;
	
	public MenuPanel(Touchy inTouchy)
	{
		mTouchy = inTouchy;
		
		this.setLayout(null);
		this.setPreferredSize(new Dimension(800,600));
		this.setBackground(Color.decode("#BFD657"));
		
		//Touchy!
		JLabel label = new JLabel("Touchy!");
		label.setFont(new Font("Arial", Font.PLAIN, 100));
		label.setBounds(this.getPreferredSize().width/2-(label.getPreferredSize().width/2), 50, label.getPreferredSize().width, label.getPreferredSize().height);
		this.add(label);
		
		//play button
		JButton button = new JButton("Play!");
		button.setFont(new Font("Arial", Font.PLAIN, 30));
		button.setActionCommand("play");
		button.addActionListener(this);
		button.setBounds(this.getPreferredSize().width/2-(button.getPreferredSize().width/2), 350, button.getPreferredSize().width, button.getPreferredSize().height);
		this.add(button);
		
		//instructions
		label = new JLabel();
		label.setFont(new Font("Arial", Font.PLAIN, 20));
		label.setText("Instructions:");
		label.setBounds(150, 180, label.getPreferredSize().width, label.getPreferredSize().height);
		this.add(label);
		
		label = new JLabel();
		label.setFont(new Font("Arial", Font.PLAIN, 20));
		label.setText(" - Enter the words before they hit the bottom\n");
		label.setBounds(150, 200, label.getPreferredSize().width, label.getPreferredSize().height);
		this.add(label);
		
		label = new JLabel();
		label.setFont(new Font("Arial", Font.PLAIN, 20));
		label.setText(" - Hit \"space\" to check if word is correct\n");
		label.setBounds(150, 220, label.getPreferredSize().width, label.getPreferredSize().height);
		this.add(label);
		
		label = new JLabel();
		label.setFont(new Font("Arial", Font.PLAIN, 20));
		label.setText(" - Correct word gives 10 points, and boost to power meter\n");
		label.setBounds(150, 240, label.getPreferredSize().width, label.getPreferredSize().height);
		this.add(label);
		
		label = new JLabel();
		label.setFont(new Font("Arial", Font.PLAIN, 20));
		label.setText(" - Wrong word gives no points, but takes from power meter\n");
		label.setBounds(150, 260, label.getPreferredSize().width, label.getPreferredSize().height);
		this.add(label);
		
		label = new JLabel();
		label.setFont(new Font("Arial", Font.PLAIN, 20));
		label.setText(" - Missed word gives 5 points, and takes tripe from power meter\n");
		label.setBounds(150, 280, label.getPreferredSize().width, label.getPreferredSize().height);
		this.add(label);
		
		label = new JLabel();
		label.setFont(new Font("Arial", Font.PLAIN, 20));
		label.setText(" - The games over if the power meter goes to zero");
		label.setBounds(150, 300, label.getPreferredSize().width, label.getPreferredSize().height);
		this.add(label);
		
		//exit button
		button = new JButton("Exit");
		button.setFont(new Font("Arial", Font.PLAIN, 15));
		button.setActionCommand("byebye");
		button.addActionListener(this);
		button.setBounds(20, 540, button.getPreferredSize().width, button.getPreferredSize().height);
		this.add(button);
		
	}
	
	public void run()
	{
	}

	public void actionPerformed(ActionEvent e)
	{
		if("play".equals(e.getActionCommand()))
		{
			mTouchy.setState(mTouchy.GAME);
		}
		
		if("byebye".equals(e.getActionCommand()))
		{
			V12.getInstance().stopTool();
		}
	}
}
